package com.cinsea.ext.cjspx;

import com.cinsea.common.ActionType;
import com.cinsea.common.BasePX;
import com.cinsea.common.Env;
import com.cinsea.common.JdbcDao;
import com.cinsea.exception.DataOperationException;
import com.cinsea.util.NumberUtil;
import com.cinsea.util.StringUtil;
import com.cinsea.workflow.model.Wfnode;

import java.util.List;
import java.util.Map;


public class FinancePX extends BasePX{
    @Override
    public void after(Map context) {
        JdbcDao jdbcDao= Env.getBean("jdbcDao");
        String actiontype= StringUtil.null2String(context.get("actiontype"));
        Wfnode node=(Wfnode)context.get("wfnode");
        String processid=(String)context.get("processid");
        //外埠差旅费报销申请开始节点 402881e939f34cc30139f3a4194e01a9
        //现金报销审批开始节点 402881b43a2456e1013a24877d6800c5
        //银行支出审批开始节点 402881b43a2456e1013a25e316ca0299
        if(actiontype.equals(ActionType.SUBMIT_WFPROCESS)&&node!=null&&(node.getId().equals("402881e939f34cc30139f3a4194e01a9")||node.getId().equals("402881b43a2456e1013a24877d6800c5")||node.getId().equals("402881b43a2456e1013a25e316ca0299"))){//申请节点提交后增加关联次数
            String updatesql_cash="update ut_cashloanzb set glcs=isnull(glcs,0)+1 where processid in (select djnumber from ut_relatecash where processid=?)";
            String updatesql_travel="update ut_travelzb set glcs=isnull(glcs,0)+1 where processid in (select danjubh from ut_relatetrip where processid=?)";
            String updatesql_business="update ut_businesszd set glcs=isnull(glcs,0)+1 where processid in (select danjubh from ut_relatebusiness where processid=?)";
            jdbcDao.update(updatesql_cash,new Object[]{processid});
            jdbcDao.update(updatesql_travel,new Object[]{processid});
            jdbcDao.update(updatesql_business,new Object[]{processid});

        }
    }
}
